package com.example.asuper.test;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import org.w3c.dom.Text;

public class Cheat extends AppCompatActivity {
    private TextView tb_answer;
    private Button bt_showAnswer;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_cheat);
        tb_answer = (TextView) findViewById(R.id.tb_answer);
        bt_showAnswer = (Button) findViewById(R.id.bt_showAnswer);
        bt_showAnswer.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = getIntent();
                tb_answer.setText(intent.getStringExtra("cheat"));
                setAnserShownResult(true);
            }
        });
        setAnserShownResult(false);
    }

    private void setAnserShownResult(boolean isAnswerShown) {
        Intent date = new Intent();
        date.putExtra("CheatResult", isAnswerShown);
        setResult(RESULT_OK, date);
    }

}
